<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@ page import="java.util.List"%>
<%@ page isELIgnored="false" %> <%--isELIgnored=true禁用EL表达式--%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
	<title>注册</title>
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/reset.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/main.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-1.12.4.min.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.min-2.1.1.js"></script>
</head>
<body>
	<div class="register_con">
		<div class="l_con fl">
			<a class="reg_logo"><img src="<%=request.getContextPath() %>/images/logo.png" style="width: 150px; height: 100px;"></a>
			<div class="reg_slogan">吃喝玩乐  ·  享受生活</div>
			<div class="reg_banner"></div>
		</div>

		<div class="r_con fr">
			<div class="reg_title clearfix">
				<h1>用户注册</h1>
				<a href="loginPage">登录</a>
			</div>
			<div class="reg_form clearfix">
				<form>
				<ul>
					<li>
                        <label>用户名:</label>
                        <input type="text" name="uName" id="uName">
                        <span class="error_tip">提示信息</span>
                    </li>
					<li>
						<label>手机号:</label>
						<input type="text" name="uPhone" id="uPhone">
						<span class="error_tip">提示信息</span>
					</li>					
					<li>
						<label>密码:</label>
						<input type="password" name="uPass" id="uPass">
						<span class="error_tip">提示信息</span>
					</li>
					<li>
						<label>确认密码:</label>
						<input type="password" name="cuPass" id="cuPass">
						<span class="error_tip">提示信息</span>
					</li>

					<li class="agreement">
						<input type="checkbox" name="allow" id="allow" checked="checked">
						<label>同意”光光的衣柜用户使用协议“</label>
						<span class="error_tip2">提示信息</span>
					</li>

				</ul>				
				</form>
			</div>
			<div>
			    <button onclick="register()">注册</button>
			</div>

		</div>

	</div>

	<div class="footer">
		<div class="foot_link">
			<a href="#">张旭光太胖</a>
			<span>|</span>
			<a href="#">张旭光太丑</a>
			<span>|</span>
			<a href="#">张旭光太虚</a>
			<span>|</span>
			<a href="#">健脑补肾丸</a>
		</div>
		<p> 北京旭光补肾技术有限公司 </p>
		<p>电话：541885418828    京ICP备*******8号</p>
	</div>
	
</body>
<script>
    function register(){
        var uName = $("#uName").val();
        if(uName ==null || uName==''){
            alert("用户名不能为空");
            return null;
        }
        var checkRole=/^((13[0 -9])|(14[5,7,9])|(15([0-3]|[5-9]))|(166)|(17[0,1,3,5,6,7,8])|(18[0-9])|(19[8|9]))\d{8}$/;
        var uPhone = $("#uPhone").val();
        if(uPhone == null || uPhone ==''){
            alert("手机号不能为空！");
            return null;
        }
        if(!checkRole.test(uPhone)){
            alert("请输入正确的手机号");
            return null;
        }
        var uPass = $("#uPass").val();
        if(uPass == null || uPass ==''){
            alert("密码不能为空！");
            return null;
        }
        var cuPass = $("#cuPass").val();
        if(uPass != cuPass){
            alert("确认输入密码错误!");
            console.info("uPass="+uPass);
            console.info("cuPass="+cuPass);
            return null;
        }
        var params= "uPhone="+uPhone+"&uPass="+uPass+"&uName="+uName;
        console.info(params);
        $.ajax({
            url:"register",
            data:params,
            type:"POST",
            success: function (str){
                if(str=="0"){
                    alert("注册失败！");
                }else if (str=="2"){
                    alert("该手机号已被注册");
                }else {
                    alert("注册成功！即将跳转到登陆页面！");
                    window.location.href="loginPage";
                }
            }
        })
    }
</script>
</html>